###############################################################################
# SuperLinks                                                                  #
# Copyright (c) 2000-2007 Greg Nolle (http://greg.nolle.co.uk)                #
###############################################################################
# This program is free software; you can redistribute it and/or modify it     #
# under the terms of the GNU General Public License as published by the Free  #
# Software Foundation; either version 2 of the License, or (at your option)   #
# any later version.                                                          #
#                                                                             #
# This program is distributed in the hope that it will be useful, but WITHOUT #
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or       #
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for   #
# more details.                                                               ##                                                                             #
# You should have received a copy of the GNU General Public License along     #
# with this program; if not, write to the Free Software Foundation, Inc.,     #
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.                 #
###############################################################################
# ControlPanel/Output/SystemOptions.pm.pl -> SystemOptions module             #
###############################################################################
# DON'T EDIT BELOW UNLESS YOU KNOW WHAT YOU'RE DOING!                         #
###############################################################################
package Skin::CP::SystemOptions;

BEGIN { require "System.pm.pl"; import System qw($SYSTEM); }
BEGIN { require "General.pm.pl"; import General qw($GENERAL); }
require "Standard.pm.pl";

use HTML::Dialog;
use strict;

sub new {
  my ($class) = @_;
  my $self    = {};
  return bless ($self, $class);
}

sub DESTROY { }

###############################################################################
# show subroutine
sub show {
  my $self = shift;
  my %in = (error => "", @_);

  my @Sections = (
    { title => "Paths", items => [
      { type => "row", item => { body => "Please fill out all the required (<font color=\"Red\"><b>*</b></font>) fields:", colspan => "2" } },
      { type => "textbox", item => { name => "DB_PATH", subject => "Database Path", required => 1, iconhelp => "The full UNIX-style path to the Database directory." } },
      { type => "textbox", item => { name => "TEMP_PATH", subject => "Temporary Path", required => 1, iconhelp => "The full UNIX-style path to the Temp directory." } },
      { type => "textbox", item => { name => "LOGS_PATH", subject => "Logs Path", required => 1, iconhelp => "The full UNIX-style path to the Logs directory." } },
      { type => "textbox", item => { name => "BACKUP_PATH", subject => "Backup Path", required => 1, iconhelp => "The full UNIX-style path to the Backups directory." } },
      { type => "textbox", item => { name => "PUBLIC_PATH", subject => "Public Path", required => 1, iconhelp => "The full UNIX-style path to the Public directory." } },
      { type => "textbox", item => { name => "CACHE_PATH", subject => "Template Cache Path", required => 1, iconhelp => "The full UNIX-style path to the template Cache directory." } }
    ]},
    { title => "URLs", items => [
      { type => "textbox", item => { name => "SCRIPT_URL", subject => "Script URL", required => 1, iconhelp => "The full URL of the main SuperLinks script." } },
      { type => "textbox", item => { name => "PUBLIC_URL", subject => "Public URL", required => 1, iconhelp => "The full URL to the Public directory." } }
    ]},
    { title => "Database Engine", items => [
      { type => "textbox", item => { name => "DB_TYPE", subject => "Database System", locked => 1 } },
      { type => "textbox", item => { name => "DB_PREFIX", subject => "Table Prefix", locked => 1 } },
      { type => "textbox", item => { name => "DB_HOST", subject => ($SYSTEM->{'DB_TYPE'} eq "oracle" ? "Oracle Home Path (ORACLE_HOME)" : "SQL Server Host/Address") } },
      { type => "textbox", item => { name => "DB_PORT", subject => ($SYSTEM->{'DB_TYPE'} eq "oracle" ? "TNS Admin Path (TNS_ADMIN)" : "SQL Server Port") } },
      { type => "textbox", item => { name => "DB_NAME", subject => "SQL Database Name" } },
      { type => "textbox", item => { name => "DB_USERNAME", subject => "SQL Database Username" } },
      { type => "textbox", item => { name => "DB_PASSWORD", subject => "SQL Database Password" } }
    ]},
    { title => "Mail Options", items => [
      { type => "radio", item => { name => "MAIL_TYPE", subject => "Mail System", required => 1, items => [{ value => "SENDMAIL", label => "Sendmail" }, { value => "SMTP", label => "SMTP" }], join => "&nbsp;", iconhelp => "The type of email system to use." } },
      { type => "textbox", item => { name => "SENDMAIL", subject => "Sendmail Path", iconhelp => "The full UNIX-style path to Sendmail or the equivalent on your server." } },
      { type => "textbox", item => { name => "SMTP_SERVER", subject => "SMTP Server", iconhelp => "The hostname of a SMTP server accessible to this web server." } }
    ]},
    { title => "Misc. Options", items => [
      { type => "radio", item => { name => "FLOCK", subject => "File Locking", required => 1, items => [{ value => "1", label => "Enable" }, { value => "0", label => "Disable" }], join => "&nbsp;", iconhelp => "Enable/disable file locking. This should only be attempted on a *NIX system, not a Windows one." } },
      { type => "radio", item => { name => "LOG_ERRORS", subject => "Error Logging", required => 1, items => [{ value => "1", label => "Enable" }, { value => "0", label => "Disable" }], join => "&nbsp;", iconhelp => "Log errors for viewing later." } },
      { type => "radio", item => { name => "SHOW_CGI_ERRORS", subject => "Detailed CGI Errors", required => 1, items => [{ value => "1", label => "Enable" }, { value => "0", label => "Disable" }], join => "&nbsp;", iconhelp => "Show detailed CGI errors with paths, variable values, etc. Not recommended on public systems." } },
      { type => "radio", item => { name => "CACHING", subject => "Caching", required => 1, items => [{ value => "none", label => "None - Dynamic Templates &amp; Delivery" }, { value => "template", label => "Template Caching" }, { value => "static", label => "Static HTML Pages" }], join => "<br>", iconhelp => "What caching system to use. None: don't use any caching. Template Caching: cache templates as Perl modules for faster execution. Static HTML Pages: Category, Resource Detail, Index, What's Cool, What's Hot and What's New pages will be built as static HTML pages for even faster execution." } },
      { type => "textbox", item => { name => "START_TAG", subject => "Template Start Tag", required => 1, iconhelp => "The character(s) used to start a template tag." } },
      { type => "textbox", item => { name => "END_TAG", subject => "Template End Tag", required => 1, iconhelp => "The character(s) used to end a template tag." } },
      { type => "selectbox", item => { name => "LOCALTIME_OFFSET", subject => "Local Timezone", iconhelp => "Your local timezone. This is used to offset the GMT time to show all times correctly for your locale.", items => [
        { value => "-12" , label => "(GMT -12:00) International Date Line West" },
        { value => "-11" , label => "(GMT -11:00) Midway Island, Samoa" },
        { value => "-10" , label => "(GMT -10:00) Hawaii" },
        { value => "-9"  , label => "(GMT -09:00) Alaska" },
        { value => "-8"  , label => "(GMT -08:00) Pacific Time (US & Canada); Tijuana" },
        { value => "-7"  , label => "(GMT -07:00) Mountain Time (US & Canada); Arizona, Chihuahua, La Paz, Mazatlan" },
        { value => "-6"  , label => "(GMT -06:00) Central Time (US & Canada); Central America, Guadalajara, Mexico City, Monterrey, Saskatchewan" },
        { value => "-5"  , label => "(GMT -05:00) Eastern Time (US & Canada); Bogota, Lima, Quito, Indiana (East)" },
        { value => "-4"  , label => "(GMT -04:00) Atlantic Time (Canada); Caracas, La Paz, Santiago" },
        { value => "-3.5", label => "(GMT -03:30) Newfoundland" },
        { value => "-3"  , label => "(GMT -03:00) Brasilia, Buenos Aires, Georgetown, Greenland" },
        { value => "-2"  , label => "(GMT -02:00) Mid-Atlantic" },
        { value => "-1"  , label => "(GMT -01:00) Azores, Cape Verde Is." },
        { value => "0"   , label => "(GMT) Greenwich Mean Time: Dublin, Edinburgh, Lisbon, London; Casablanca, Monrovia" },
        { value => "1"   , label => "(GMT +01:00) Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna, Belgrade, Bratislava, Budapest, Ljubljana, Prague, Brussels, Copenhagen, Madrid, Paris, Sarajevo, Skopje, Warsaw, Zagreb, West Central Africa" },
        { value => "2"   , label => "(GMT +02:00) Athens, Istanbul, Minsk, Bucharest, Cairo, Harare, Pretoria, Helsinki, Kyiv, Riga, Sofia, Tallinn, Vilnius, Jerusalem" },
        { value => "3"   , label => "(GMT +03:00) Baghdad, Kuwait, Riyadh, Moscow, St. Petersburg, Volgograd, Nairobi" },
        { value => "3.5" , label => "(GMT +03:30) Tehran" },
        { value => "4"   , label => "(GMT +04:00) Abu Dhabi, Muscat, Baku, Tbilsi, Yerevan" },
        { value => "4.5" , label => "(GMT +04:30) Kabul" },
        { value => "5"   , label => "(GMT +05:00) Ekaterinburg, Islamabad, Karachi, Tashkent" },
        { value => "5.5" , label => "(GMT +05:30) Chennai, Kolkata, Mumbai, New Delhi" },
        { value => "5.75", label => "(GMT +05:45) Kathmandu" },
        { value => "6"   , label => "(GMT +06:00) Almaty, Novosibirsk, Astana, Dhaka, Sri Jayawarenepura" },
        { value => "6.5" , label => "(GMT +06:30) Rangoon" },
        { value => "7"   , label => "(GMT +07:00) Bankok, Hanoi, Jakarta, Krasnoyarsk" },
        { value => "8"   , label => "(GMT +08:00) Beijing, Chongqing, Hong Kong, Urumqi, Irkutsk, Ulaan Bataar, Kuala Lumpur, Singapore, Perth, Taipei" },
        { value => "9"   , label => "(GMT +09:00) Osaka, Sapporo, Tokyo, Seoul, Yakutsk" },
        { value => "9.5" , label => "(GMT +09:30) Adelaide, Darwin" },
        { value => "10"  , label => "(GMT +10:00) Brisbane, Canberra, Melbourne, Sydney, Guam, Port Moresby, Hobart, Vladivostok" },
        { value => "11"  , label => "(GMT +11:00) Magadan, Soloman Is., New Caledonia" },
        { value => "12"  , label => "(GMT +12:00) Auckland, Wellington, Fiji, Kamchatka, Marshall Is." },
        { value => "13"  , label => "(GMT +13:00) Nuku'alofa" }
      ]}},
      { type => "checkbox", item => { name => "LOCALTIME_DST", items => [{ value => "1", label => "Automatically adjust time for daylight saving changes?" }] } },
      { type => "selectbox", item => { name => "CHARSET", subject => "Character Set", required => 1, iconhelp => "The character set that should be used in all HTML screens and emails generated by SuperLinks.", items => [
        { value => "ASMO-708", label => "Arabic (ASMO 708) [ASMO-708]" },
        { value => "DOS-720", label => "Arabic (DOS) [DOS-720]" },
        { value => "iso-8859-6", label => "Arabic (ISO) [iso-8859-6]" },
        { value => "x-mac-arabic", label => "Arabic (Mac) [x-mac-arabic]" },
        { value => "windows-1256", label => "Arabic (Windows) [windows-1256]" },
        { value => "ibm775", label => "Baltic (DOS) [ibm775]" },
        { value => "iso-8859-4", label => "Baltic (ISO) [iso-8859-4]" },
        { value => "windows-1257", label => "Baltic (Windows) [windows-1257]" },
        { value => "ibm852", label => "Central European (DOS) [ibm852]" },
        { value => "iso-8859-2", label => "Central European (ISO) [iso-8859-2]" },
        { value => "x-mac-ce", label => "Central European (Mac) [x-mac-ce]" },
        { value => "windows-1250", label => "Central European (Windows) [windows-1250]" },
        { value => "EUC-CN", label => "Chinese Simplified (EUC) [EUC-CN]" },
        { value => "gb2312", label => "Chinese Simplified (GB2312) [gb2312]" },
        { value => "hz-gb-2312", label => "Chinese Simplified (HZ) [hz-gb-2312]" },
        { value => "x-mac-chinesesimp", label => "Chinese Simplified (Mac) [x-mac-chinesesimp]" },
        { value => "big5", label => "Chinese Traditional (Big5) [big5]" },
        { value => "x-Chinese-CNS", label => "Chinese Traditional (CNS) [x-Chinese-CNS]" },
        { value => "x-Chinese-Eten", label => "Chinese Traditional (Eten) [x-Chinese-Eten]" },
        { value => "x-mac-chinesetrad", label => "Chinese Traditional (Mac) [x-mac-chinesetrad]" },
        { value => "cp866", label => "Cyrillic (DOS) [cp866]" },
        { value => "iso-8859-5", label => "Cyrillic (ISO) [iso-8859-5]" },
        { value => "koi8-r", label => "Cyrillic (KOI8-R) [koi8-r]" },
        { value => "koi8-u", label => "Cyrillic (KOI8-U) [koi8-u]" },
        { value => "x-mac-cyrillic", label => "Cyrillic (Mac) [x-mac-cyrillic]" },
        { value => "windows-1251", label => "Cyrillic (Windows) [windows-1251]" },
        { value => "x-Europa", label => "Europa [x-Europa]" },
        { value => "x-IA5-German", label => "German (IA5) [x-IA5-German]" },
        { value => "ibm737", label => "Greek (DOS) [ibm737]" },
        { value => "iso-8859-7", label => "Greek (ISO) [iso-8859-7]" },
        { value => "x-mac-greek", label => "Greek (Mac) [x-mac-greek]" },
        { value => "windows-1253", label => "Greek (Windows) [windows-1253]" },
        { value => "ibm869", label => "Greek, Modern (DOS) [ibm869]" },
        { value => "DOS-862", label => "Hebrew (DOS) [DOS-862]" },
        { value => "iso-8859-8-i", label => "Hebrew (ISO-Logical) [iso-8859-8-i]" },
        { value => "iso-8859-8", label => "Hebrew (ISO-Visual) [iso-8859-8]" },
        { value => "x-mac-hebrew", label => "Hebrew (Mac) [x-mac-hebrew]" },
        { value => "windows-1255", label => "Hebrew (Windows) [windows-1255]" },
        { value => "x-EBCDIC-Arabic", label => "IBM EBCDIC (Arabic) [x-EBCDIC-Arabic]" },
        { value => "x-EBCDIC-CyrillicRussian", label => "IBM EBCDIC (Cyrillic Russian) [x-EBCDIC-CyrillicRussian]" },
        { value => "x-EBCDIC-CyrillicSerbianBulgarian", label => "IBM EBCDIC (Cyrillic Serbian-Bulgarian) [x-EBCDIC-CyrillicSerbianBulgarian]" },
        { value => "x-EBCDIC-DenmarkNorway", label => "IBM EBCDIC (Denmark-Norway) [x-EBCDIC-DenmarkNorway]" },
        { value => "x-ebcdic-denmarknorway-euro", label => "IBM EBCDIC (Denmark-Norway-Euro) [x-ebcdic-denmarknorway-euro]" },
        { value => "x-EBCDIC-FinlandSweden", label => "IBM EBCDIC (Finland-Sweden) [x-EBCDIC-FinlandSweden]" },
        { value => "x-ebcdic-finlandsweden-euro", label => "IBM EBCDIC (Finland-Sweden-Euro) [x-ebcdic-finlandsweden-euro]" },
        { value => "x-ebcdic-finlandsweden-euro", label => "IBM EBCDIC (Finland-Sweden-Euro) [x-ebcdic-finlandsweden-euro]" },
        { value => "x-ebcdic-france-euro", label => "IBM EBCDIC (France-Euro) [x-ebcdic-france-euro]" },
        { value => "x-EBCDIC-Germany", label => "IBM EBCDIC (Germany) [x-EBCDIC-Germany]" },
        { value => "x-ebcdic-germany-euro", label => "IBM EBCDIC (Germany-Euro) [x-ebcdic-germany-euro]" },
        { value => "x-EBCDIC-GreekModern", label => "IBM EBCDIC (Greek Modern) [x-EBCDIC-GreekModern]" },
        { value => "x-EBCDIC-Greek", label => "IBM EBCDIC (Greek) [x-EBCDIC-Greek]" },
        { value => "x-EBCDIC-Hebrew", label => "IBM EBCDIC (Hebrew) [x-EBCDIC-Hebrew]" },
        { value => "x-EBCDIC-Icelandic", label => "IBM EBCDIC (Icelandic) [x-EBCDIC-Icelandic]" },
        { value => "x-ebcdic-icelandic-euro", label => "IBM EBCDIC (Icelandic-Euro) [x-ebcdic-icelandic-euro]" },
        { value => "x-ebcdic-international-euro", label => "IBM EBCDIC (International-Euro) [x-ebcdic-international-euro]" },
        { value => "x-EBCDIC-Italy", label => "IBM EBCDIC (Italy) [x-EBCDIC-Italy]" },
        { value => "x-ebcdic-italy-euro", label => "IBM EBCDIC (Italy-Euro) [x-ebcdic-italy-euro]" },
        { value => "x-EBCDIC-JapaneseAndKana", label => "IBM EBCDIC (Japanese and Japanese Katakana) [x-EBCDIC-JapaneseAndKana]" },
        { value => "x-EBCDIC-JapaneseAndJapaneseLatin", label => "IBM EBCDIC (Japanese and Japanese-Latin) [x-EBCDIC-JapaneseAndJapaneseLatin]" },
        { value => "x-EBCDIC-JapaneseAndUSCanada", label => "IBM EBCDIC (Japanese and US-Canada) [x-EBCDIC-JapaneseAndUSCanada]" },
        { value => "x-EBCDIC-JapaneseKatakana", label => "IBM EBCDIC (Japanese katakana) [x-EBCDIC-JapaneseKatakana]" },
        { value => "x-EBCDIC-KoreanAndKoreanExtended", label => "IBM EBCDIC (Korean and Korean Extended) [x-EBCDIC-KoreanAndKoreanExtended]" },
        { value => "x-EBCDIC-KoreanExtended", label => "IBM EBCDIC (Korean Extended) [x-EBCDIC-KoreanExtended]" },
        { value => "CP870", label => "IBM EBCDIC (Multilingual Latin-2) [CP870]" },
        { value => "x-EBCDIC-SimplifiedChinese", label => "IBM EBCDIC (Simplified Chinese) [x-EBCDIC-SimplifiedChinese]" },
        { value => "X-EBCDIC-Spain", label => "IBM EBCDIC (Spain) [X-EBCDIC-Spain]" },
        { value => "x-ebcdic-spain-euro", label => "IBM EBCDIC (Spain-Euro) [x-ebcdic-spain-euro]" },
        { value => "x-EBCDIC-Thai", label => "IBM EBCDIC (Thai) [x-EBCDIC-Thai]" },
        { value => "x-EBCDIC-TraditionalChinese", label => "IBM EBCDIC (Traditional Chinese) [x-EBCDIC-TraditionalChinese]" },
        { value => "CP1026", label => "IBM EBCDIC (Turkish Latin-5) [CP1026]" },
        { value => "x-EBCDIC-Turkish", label => "IBM EBCDIC (Turkish) [x-EBCDIC-Turkish]" },
        { value => "x-EBCDIC-UK", label => "IBM EBCDIC (UK) [x-EBCDIC-UK]" },
        { value => "x-ebcdic-uk-euro", label => "IBM EBCDIC (UK-Euro) [x-ebcdic-uk-euro]" },
        { value => "ebcdic-cp-us", label => "IBM EBCDIC (US-Canada) [ebcdic-cp-us]" },
        { value => "x-ebcdic-cp-us-euro", label => "IBM EBCDIC (US-Canada-Euro) [x-ebcdic-cp-us-euro]" },
        { value => "ibm861", label => "Icelandic (DOS) [ibm861]" },
        { value => "x-mac-icelandic", label => "Icelandic (Mac) [x-mac-icelandic]" },
        { value => "x-iscii-as", label => "ISCII Assamese [x-iscii-as]" },
        { value => "x-iscii-be", label => "ISCII Bengali [x-iscii-be]" },
        { value => "x-iscii-de", label => "ISCII Devanagari [x-iscii-de]" },
        { value => "x-iscii-gu", label => "ISCII Gujarathi [x-iscii-gu]" },
        { value => "x-iscii-ka", label => "ISCII Kannada [x-iscii-ka]" },
        { value => "x-iscii-ma", label => "ISCII Malayalam [x-iscii-ma]" },
        { value => "x-iscii-or", label => "ISCII Oriya [x-iscii-or]" },
        { value => "x-iscii-pa", label => "ISCII Panjabi [x-iscii-pa]" },
        { value => "x-iscii-ta", label => "ISCII Tamil [x-iscii-ta]" },
        { value => "x-iscii-te", label => "ISCII Telugu [x-iscii-te]" },
        { value => "euc-jp", label => "Japanese (EUC) [euc-jp]" },
        { value => "iso-2022-jp", label => "Japanese (JIS) [iso-2022-jp]" },
        { value => "iso-2022-jp", label => "Japanese (JIS-Allow 1 byte Kana - SO/SI) [iso-2022-jp]" },
        { value => "csISO2022JP", label => "Japanese (JIS-Allow 1 byte Kana) [csISO2022JP]" },
        { value => "x-mac-japanese", label => "Japanese (Mac) [x-mac-japanese]" },
        { value => "shift_jis", label => "Japanese (Shift-JIS) [shift_jis]" },
        { value => "ks_c_5601-1987", label => "Korean [ks_c_5601-1987]" },
        { value => "euc-kr", label => "Korean (EUC) [euc-kr]" },
        { value => "iso-2022-kr", label => "Korean (ISO) [iso-2022-kr]" },
        { value => "Johab", label => "Korean (Johab) [Johab]" },
        { value => "x-mac-korean", label => "Korean (Mac) [x-mac-korean]" },
        { value => "iso-8859-3", label => "Latin 3 (ISO) [iso-8859-3]" },
        { value => "iso-8859-15", label => "Latin 9 (ISO) [iso-8859-15]" },
        { value => "x-IA5-Norwegian", label => "Norwegian (IA5) [x-IA5-Norwegian]" },
        { value => "IBM437", label => "OEM United States [IBM437]" },
        { value => "x-IA5-Swedish", label => "Swedish (IA5) [x-IA5-Swedish]" },
        { value => "windows-874", label => "Thai (Windows) [windows-874]" },
        { value => "ibm857", label => "Turkish (DOS) [ibm857]" },
        { value => "iso-8859-9", label => "Turkish (ISO) [iso-8859-9]" },
        { value => "x-mac-turkish", label => "Turkish (Mac) [x-mac-turkish]" },
        { value => "windows-1254", label => "Turkish (Windows) [windows-1254]" },
        { value => "unicode", label => "Unicode [unicode]" },
        { value => "unicodeFFFE", label => "Unicode (Big-Endian) [unicodeFFFE]" },
        { value => "utf-7", label => "Unicode (UTF-7) [utf-7]" },
        { value => "utf-8", label => "Unicode (UTF-8) [utf-8]" },
        { value => "us-ascii", label => "US-ASCII [us-ascii]" },
        { value => "windows-1258", label => "Vietnamese (Windows) [windows-1258]" },
        { value => "ibm850", label => "Western European (DOS) [ibm850]" },
        { value => "x-IA5", label => "Western European (IA5) [x-IA5]" },
        { value => "iso-8859-1", label => "Western European (ISO) [iso-8859-1]" },
        { value => "macintosh", label => "Western European (Mac) [macintosh]" },
        { value => "Windows-1252", label => "Western European (Windows) [Windows-1252]" }
      ]}},
      { type => "divider", item => { colspan => 2 } },
      { type => "button", item => { items => [{ type => "submit", value => "Modify" }, { type => "reset", value => "Cancel" }], join => "&nbsp;" } }
    ]},
  );

  my $LANGUAGE = {
    "MISSING" => { },
    "ERROR"   => qq~<p><font class="error">There were errors:<ul>[%error%]</ul></font>~
  };
  
  foreach my $section (@Sections) {
    foreach my $item (@{ $section->{'items'} }) {
      $LANGUAGE->{'MISSING'}->{ $item->{'item'}->{'name'} } = qq~<li>You didn't fill in the "$item->{'item'}->{'subject'}" field.~ if ($item->{'item'}->{'subject'});
    }
  }
  
  $in{'error'} = &Standard::ProcessError(LANGUAGE => $LANGUAGE, ERROR => $in{'error'});
  $Sections[0]->{'items'}->[0]->{'item'}->{'body'} .= $in{'error'};

  #----------------------------------------------------------------------#
  # Printing page...                                                     #

  my $Dialog = HTML::Dialog->new();

  my $Body;
  foreach my $section (@Sections) {
    $Body .= $Dialog->TableHeader(titles => [{ title => $section->{'title'}, colspan => 2, align => "left" }]) if ($section->{'title'});
    
    foreach my $item (@{ $section->{'items'} }) {
      if ($item->{'type'} eq "textbox") {
        $item->{'item'}->{'value'} = $SYSTEM->{ $item->{'item'}->{'name'} } unless (defined($item->{'item'}->{'value'}));
        $item->{'item'}->{'name'}  = "FORM_".$item->{'item'}->{'name'};
        $item->{'item'}->{'name'}  = "" if ($item->{'item'}->{'locked'});
        $Body .= $Dialog->FormTextBox(%{ $item->{'item'} });
      } elsif ($item->{'type'} eq "textarea") {
        $item->{'item'}->{'value'} = $SYSTEM->{ $item->{'item'}->{'name'} } unless (defined($item->{'item'}->{'value'}));
        $item->{'item'}->{'name'}  = "FORM_".$item->{'item'}->{'name'};
        $item->{'item'}->{'name'}  = "" if ($item->{'item'}->{'locked'});
        $Body .= $Dialog->FormTextArea(%{ $item->{'item'} });
      } elsif ($item->{'type'} eq "radio") {
        $item->{'item'}->{'value'} = $SYSTEM->{ $item->{'item'}->{'name'} } unless (defined($item->{'item'}->{'value'}));
        $item->{'item'}->{'name'}  = "FORM_".$item->{'item'}->{'name'};
        $item->{'item'}->{'name'}  = "" if ($item->{'item'}->{'locked'});
        $Body .= $Dialog->FormRadio(%{ $item->{'item'} });
      } elsif ($item->{'type'} eq "checkbox") {
        $item->{'item'}->{'value'} = $SYSTEM->{ $item->{'item'}->{'name'} } unless (defined($item->{'item'}->{'value'}));
        $item->{'item'}->{'name'}  = "FORM_".$item->{'item'}->{'name'};
        $item->{'item'}->{'name'}  = "" if ($item->{'item'}->{'locked'});
        $Body .= $Dialog->FormCheckBox(%{ $item->{'item'} });
      } elsif ($item->{'type'} eq "selectbox") {
        $item->{'item'}->{'value'} = $SYSTEM->{ $item->{'item'}->{'name'} } unless (defined($item->{'item'}->{'value'}));
        $item->{'item'}->{'name'} = "FORM_".$item->{'item'}->{'name'};
        $item->{'item'}->{'name'}  = "" if ($item->{'item'}->{'locked'});
        $Body .= $Dialog->FormSelectBox(%{ $item->{'item'} });
      } elsif ($item->{'type'} eq "row") {
        $Body .= $Dialog->TableRow(items => [$item->{'item'}]);
      } elsif ($item->{'type'} eq "button") {
        $Body .= $Dialog->FormButton(%{ $item->{'item'} });        
      } elsif ($item->{'type'} eq "divider") {
        $Body .= $Dialog->TableDivider(%{ $item->{'item'} });
      }
    }
  }
  
  $Body = $Dialog->Table(body => $Body);
  $Body = $Dialog->StandardPage(
    body        => $Body,
    header      => "System Options",
    head_extra  => "<script src=\"$SYSTEM->{'PUBLIC_URL'}/functions.js\"></script>",
    form        => 1,
    hiddens     => [
      { name => "action", value => "DoSystemOptions" },
      { name => "CP", value => "1" },
      { name => "SID", value => $SL::ADMIN{'SID'} }
    ]
  );

  return $Body;
}

###############################################################################
# do subroutine
sub do {
  my $self = shift;

  #----------------------------------------------------------------------#
  # Printing page...                                                     #

  my $Dialog = HTML::Dialog->new();

  return $Dialog->StandardPage(
    body    => qq~The system options have been updated.<p>Click <a href="$SYSTEM->{'SCRIPT_URL'}?CP=1&action=Summary&SID=$SL::ADMIN{'SID'}">here</a> if you're not redirected in 5 seconds.~,
    header  => "System Options",
    metas   => [
      { http_equiv => "refresh", content => "5; url=$SYSTEM->{'SCRIPT_URL'}?CP=1&action=Summary&SID=$SL::ADMIN{'SID'}" }
    ]
  );
}

1;